static-lib=libmymath.a # 库名
dynamics-lib=libmymethod.so

.PHONY:all
all: $(dynamics-lib)  $(static-lib)
# 库由什么形成的：目标文件 
$(static-lib):mymath.o
# 库的形成指令
# rc表示(replace and create)
	ar -rc $@ $^
mymath.o:mymath.c
# gcc 编译到目标文件
	gcc -c $^ 

$(dynamics-lib):mylog.o print.o
	gcc -shared -o $@ $^
mylog.o:mylog.c
	gcc -fPIC -c mylog.c
print.o:print.c
	gcc -fPIC -c print.c

.PHONY:clean
clean:
	rm -rf *.o *.a .*so mylib

.PHONY:output
output:
	mkdir -p mylib/include
	mkdir -p mylib/lib
	cp *.h mylib/include 
	cp *.a mylib/lib
	cp *.so mylib/lib